//创建容器
import { createStore } from "vuex";

import {getItem,setItem } from "../utils/storage";
const TOKEN_KEY="TOUTIAO_USER";
const store=createStore({
    state: {
         //user:JSON.parse(window.localStorage.getItem(TOKENT_KEY))
         user:getItem(TOKEN_KEY),
    },
    mutations:{
        setUser(state, data){
        state.user=data;
        setItem(TOKEN_KEY,state.user);
        //window.localStorage.setItem(TOKENT_KEY,JSON.stringify(state.user));
        }
    }
});
export default store;